package org.xiyinjihe.platform.config;

import org.xiyinjihe.platform.interceptor.PermissionInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter   {

    @Bean
    public PermissionInterceptor getPermissionInterceptor(){
        return new PermissionInterceptor();
    }

    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // /**  表示拦截所有路径下的所有请求
        registry.addInterceptor(getPermissionInterceptor()).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
